Skip to content

Add dynamic library support for CLIgen extensions#136

Closed
khromenokroman wants to merge 3 commits intoclicon:masterfrom
khromenokroman:extended_output
Closed

Add dynamic library support for CLIgen extensions#136
khromenokroman wants to merge 3 commits intoclicon:masterfrom
khromenokroman:extended_output

Conversation

@khromenokroman
Copy link
Contributor

@olofhagsand
Introduced mechanisms to dynamically load and inject custom match result handling via shared libraries using dlopen and dlsym. Updated relevant structures and functions to support this functionality.

khromenokroman and others added 2 commits January 15, 2026 16:54
Introduced mechanisms to dynamically load and inject custom match result handling via shared libraries using `dlopen` and `dlsym`. Updated relevant structures and functions to support this functionality.
@codecov
Copy link

codecov bot commented Jan 15, 2026

Codecov Report

❌ Patch coverage is 64.28571% with 15 lines in your changes missing coverage. Please review.
✅ Project coverage is 53.24%. Comparing base (e208db7) to head (088f424).

Files with missing lines Patch % Lines
cligen_read.c 58.06% 11 Missing and 2 partials ⚠️
cligen_handle.c 81.81% 1 Missing and 1 partial ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #136      +/-   ##
==========================================
- Coverage   53.25%   53.24%   -0.02%     
==========================================
  Files          23       23              
  Lines        7776     7806      +30     
  Branches     1797     1804       +7     
==========================================
+ Hits         4141     4156      +15     
- Misses       2607     2619      +12     
- Partials     1028     1031       +3     
Files with missing lines Coverage Δ
cligen_handle.c 57.74% <81.81%> (+0.71%) ⬆️
cligen_read.c 55.47% <58.06%> (-0.91%) ⬇️

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e208db7...088f424. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@olofhagsand
Copy link
Member

Why would you want that, what is the usecase?
There is already a dl mechanism in clixon you can use to dynamically add symbols for callbacks, helptexts, etc.
If there is something that you want to extend, please do that on a clixon api level instead, I dont want to add a dl extension layer in cligen as well.
If this is related to the expand-dbvar discussion in matrix, I would rather add an indirection layer (or callback mechanism) in expand-dbvar instead in clixon.

@khromenokroman
Copy link
Contributor Author

khromenokroman commented Jan 15, 2026

@olofhagsand
I want the user in the client to receive a list of current mac addresses when clicked, which he does not fill out in advance.

sysadmin@eve-img:/> set system interface management mgmt0 mac-address
50:02:00:88:00:00 Interface is enp0s2
50:02:00:88:00:03 Interface is enp0s5
50:02:00:88:00:04 Interface is enp0s6

an important note is that where this is inserted is declared in yang

in the cli, it's done like this
set @datamodel, cli_auto_set();
I can't use dbvar.

@khromenokroman
Copy link
Contributor Author

There is already a dl mechanism in clixon you can use to dynamically add symbols for callbacks, helptexts, etc.
If there is something that you want to extend, please do that on a clixon api level instead, I dont want to add a dl extension layer in cligen as well.

@olofhagsand
yes it is, but it only works for runtime commands. to do this, I have to describe them in the .cli, but if I have
set @datamodel, cli_auto_set(); unfortunately, I can't do that.

and what I need is inside the generated cli inside the set.

@olofhagsand
Copy link
Member

One could extend he syntax to make the expand function configurable,
two ideas could be:

  1. set @datamodel, cli_auto_set(), myexpand();
  2. or to make a yang cli extension where you tag the YANG with another expand function

@khromenokroman
Copy link
Contributor Author

2. or to make a yang cli extension where you tag the YANG with another expand function

this will only work when the client is running, and if something has changed in runtime, I will not be able to update it.

@khromenokroman
Copy link
Contributor Author

  1. set @datamodel, cli_auto_set(), myexpand();

is this, as I understand it, not implemented? or is it already there? if there is a place to read about it?

@olofhagsand
Copy link
Member

No it is not implemented.

@khromenokroman
Copy link
Contributor Author

@olofhagsand Maybe we can add this solution for now, and fix it as soon as another one appears? I really need this functionality now. And to do this, set @datamodel, cli_auto_set(), myexpand(); I don't know how yet.

@olofhagsand
Copy link
Member

You can add this on your local repo if you like. I will not add an intermediate solution in upstream.
BTW, a third option is to add a callback in expand_dbvar itself, which is probably the easiest to implement. I.e., expand_dbvar would call that callback function if it exists, if not it would return the default expand function.
This is something one could implement relatively easy.
In other words, add another indirection in the autocli code (lib/src/clixon_autocli_generate.c) , ie instead of:

/* variable expand function */
#define GENERATE_EXPAND_XMLDB "expand_dbvar"

As a first step, instead of it being fixed in C, it could be added to include/clixon_custom.h or in configure.ac.
As a second step, it could be a callback function for the CLI which you register in clixon_plugin_init().
This would be straightforward.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants